
#ifndef _UTIL2_
#define _UTIL2_

#include <dvdmedia.h>

HRESULT SaveGraphFile(IGraphBuilder *pGraph, WCHAR *wszPath);

class C_SaveToLog {
	FILE *fp;
	char fileName[125];

	int index;
	char string[1024];

public :
	C_SaveToLog(char*str = NULL) {
		if(str == NULL) 
			strcpy(fileName, "log.txt");
		else 
			strcpy(fileName, str);

		fp = fopen(fileName, "w");

		fprintf(fp, "<Log file> \n ");

		index = 0;
	}

	~C_SaveToLog() {
		if(fp)
			fclose(fp);
	}

	void ToLog(char* str) {
		if(fp)
			fprintf(fp, "%s", str);
	}

	void ToLog(int input) {
		if(fp)
			fprintf(fp, "%d", input);
	}

	void ToLog(char* str, int len) {
		if(fp) {
			char tmp[1024];
			strncpy(tmp, str, len);
			strcat(tmp, "");
			fprintf(fp, "\n Len(%d) : %s", len, tmp);
		}
	}

	void ToLog16(char* str, int len) {
		if(fp) {
			char tmp[1024];
			strncpy(tmp, str, len);
			strcat(tmp, "");
			fprintf(fp, "\n Len(%d) : %d", len, tmp);
			for(int i = 0; i < len; i++) 
				fprintf(fp, "\n %x", tmp[i]);
		}
	}

	void CleanStr(void) {
		index = 0;
	}

	void ToStr(char* str) {
		strcpy(&string[index], str);
		index += strlen(string);
	}

	void ToStr(int input) {
		char str[100];

		itoa(input, str, 10);
		strcpy(&string[index], str);
		index += strlen(string);
	}

	void SaveStr(void) {
		if(fp)
			fprintf(fp, "\n%s", string);
	}
};


#ifdef _MAIN_
class C_SaveToLog SaveLog(NULL);
#else 
extern class C_SaveToLog SaveLog;
#endif


#endif